package com.javasm.finance.service.impl;

import com.javasm.finance.dao.ProductCategoryDao;
import com.javasm.finance.dao.impl.ProductCategoryDaoImpl;
import com.javasm.finance.entity.ProdChannel;
import com.javasm.finance.entity.ProductCategory;
import com.javasm.finance.entity.User;
import com.javasm.finance.service.ProductCategoryService;

import java.sql.SQLException;
import java.util.List;

public class ProductCategoryServiceImpl implements ProductCategoryService {
    ProductCategoryDao productCategoryDao=new ProductCategoryDaoImpl();

    @Override
    public List<ProductCategory> queryProductCategory(Integer page, Integer pageSize, String prodName) {
        List<ProductCategory> productCategories = null;
        try {
            productCategories = productCategoryDao.queryProductCategory(page, pageSize, prodName);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return productCategories;
    }

    @Override
    public long findTotalNum(String prodName) {
        long totalNum = 0;
        try {
            totalNum = productCategoryDao.findTotalNum(prodName);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return totalNum;
    }

    @Override
    public int addProductCategory(ProductCategory productCategory) {
        int rows = 0;
        try {
            rows = productCategoryDao.addProductCategory(productCategory);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }

    @Override
    public ProductCategory findByPid(Integer prodId) {
        ProductCategory productCategory = null;
        try {
            productCategory = productCategoryDao.findByPid(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return productCategory;
    }

    @Override
    public int editProd(ProductCategory productCategory) {
        int rows = 0;
        try {
            rows = productCategoryDao.editProd(productCategory);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }

    @Override
    public List<ProdChannel> queryChannel() {
        List<ProdChannel> list=null;
        try {
             list = productCategoryDao.queryChannel();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return list;
    }

    @Override
    public ProductCategory findByPidRemi(Integer prodId) {
        ProductCategory productCategory = null;
        try {
            productCategory = productCategoryDao.findByPidRemi(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return productCategory;
    }

    @Override
    public int addRemi(ProductCategory productCategory) {
        int rows = 0;
        try {
            rows = productCategoryDao.addRemi(productCategory);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }

    @Override
    public int deleteProd(Integer prodId) {
        int rows = 0;
        try {
            rows = productCategoryDao.deleteProd(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }
}
